package io.zim.modules.app.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.zim.common.utils.R;
import io.zim.modules.app.entity.AdVo;
import io.zim.modules.app.service.ApiAdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 广告api
 * @author zzh
 * @email 862583291@qq.com
 * @date 2019-01-14 12:27
 */
@Api("广告api")
@RestController
@RequestMapping("/app/ad")
public class ApiAdController {

  @Autowired
  private ApiAdService adService;

  /**
   * app轮播广告
   */
  @ApiOperation("app轮播广告")
  @GetMapping("banner")
  public Object banner() {
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("ad_position_id", 1);
    param.put("enabled", 1);
    List<AdVo> banners = adService.list(
        new QueryWrapper<AdVo>()
            .eq("ad_position_id", 1)
            .eq("enabled", 1)
    );
    return R.ok().put("data", banners);
  }
}
